<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>项目阶段设置</title>
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--公用样式-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/common/css/comment.css">
    <!--页面样式-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/common/css/style.css">
    <link rel="stylesheet" href="${re.contextPath}/plugin/common/css/extended.css">
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
</head>
<body class="whitebg">
<div class="myDataCentere mydataCentere-small addformstage" style="height: 500px!important;">

    <form id="myForm"  style="height: 500px" class="layui-form">

<#--        <div class="layui-form-item">-->
<#--            <label class="layui-form-label"><span class="red">*</span>标段</label>-->
<#--            <div class="layui-input-block">-->
<#--                <div style="display: flow-root;" class="wp42 h35">-->
<#--                    <div class="slt" id="cjCompany" style="width: 500px"></div>-->
<#--                </div>-->
<#--            </div>-->
<#--        </div>-->

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>承建单位</label>
            <div class="layui-input-block">
                <div style="display: flow-root;" class="wp42 h35">
                    <div class="slt" id="cjCompany" style="width: 500px"></div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label >
                <label class="layui-form-label"><span class="red">*</span>消息内容</label>
            </label>
            <div class="fl wp42 h35">
                <textarea name="desc"  id="content"  style="width: 500px;height: 100px;"  lay-verify="content" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div style="margin-left: 30px;margin-top: 200px;padding-left:100px;clear: both;">
            <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">
                保存
            </button>
            <button class="layui-btn layui-btn-primary" id="close">
                关闭
            </button>
        </div>
    </form>


</div>

<#-- 可以多选的下拉框 -->
<script src="${re.contextPath}/plugin/layui/xm-select.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script>
    var fbId = "${fbId}";
    var projectId = "${projectId}";
    var parentId = "${parentId}";
    var xmselectcompany;
    $(function () {
        layerAjaxGet("/project/projectManager/getCjdw", {}, "", function (d) {
            var rows = null;
            if (d.code == 200) {
                if (d.data) {
                    rows = d.data;
                }
                if (rows) {
                    var _ycols = ['id', 'realName', 'unitConstruction'];
                    var xmjlry = [];
                    console.log(rows, "88888888888888888888888");
                    $.each(rows, function (i, v) {
                        xmjlry.push({name: v[_ycols[2]]+"--"+v[_ycols[1]], value: v[_ycols[0]]});
                    })

                    // 绑定项目经理下拉
                    xmselectcompany = xmSelect.render({
                        el: '#cjCompany',
                        filterable: true,
                        disabled: false,
                        toolbar: {show: true},
                        layVerType: 'msg',
                        on: function (data) {
                            if (data && data.arr.length > 0) {
                                // _crt_page.forms.selects.companychange(data.arr[0].value);
                            }
                        },
                        data: xmjlry
                    })
                }
            }

        });


    })
    var autocomplete, dropdown;

    layui.use(['form', 'layer', 'laydate'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer, laydate = layui.laydate;

        $('#close').click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });

        laydate.render({
            elem: '#startDate'
            , format: 'yyyy-MM-dd',
            trigger: 'click'
        });
        laydate.render({
            elem: '#endDate',
            format: 'yyyy-MM-dd',
            trigger: 'click'
        });
        // 自定义验证规则
        form.verify({
            content: function (value) {
                if (value.trim() == "") {
                    return '消息内容不能为空';
                }
            }
        })
        form.on('submit(add)', function (data) {
            var selectCj = xmselectcompany.getValue('valueStr');
            if (!selectCj) {
                layer.msg("请选择承建单位", {icon: 2});
                return false;
            }
            var content = $('#content').val();
            var json = {
                content: content,
                selectCj: selectCj,
            }
            layerAjax('/project/projectManager/notice/noticeAdd', json, '',
                function (d) {
                    console.log(d);
                    if (d.flag == true) {
                        parent.layer.msg(d.msg, {icon: 1});
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else {
                        layer.msg(d.msg, {icon: 2});
                    }
                });
            return false;
        });
    });
</script>
</body>

<style>
    .addformstage {
        margin-left: 100px;
        height: 100%;
        background-color: white;


    }
</style>


</html>
